function set_input_focus()
{
    // set focus high-light for all input[text | password]
    $('input:text,input:password,textarea').focus(function()
    {
        $(this).addClass('focus');
    });

    $('input:text,input:password,textarea').blur(function()
    {
        $(this).removeClass('focus');
    });

    $('input:first').focus();
}

$(function()
{
    $("#dob").datepicker({
                    dateFormat: 'dd-mm-yy',
                    changeYear: true,
                    changeMonth: true,
                    yearRange:"-90:+0"
            }
    );
    $("#start_date").datepicker({
                    dateFormat: 'dd-mm-yy',
                    changeYear: true,
                    changeMonth: true,
                    yearRange:"-90:+0"
            }
    );
    $("#end_date").datepicker({
                    dateFormat: 'dd-mm-yy',
                    changeYear: true,
                    changeMonth: true,
                    yearRange:"-90:+0"
            }
    );
});

function enable_simple_wysiwyg(selector)
{
    tinyMCE.init({
        mode : "textareas",
        editor_selector : selector,
        theme : "advanced",
        invalid_elements : "div,script,abbr,acronym,address,applet,area,bdo,big,blockquote,button,caption,cite,code,col,colgroup,dd,del,dfn,iframe,input,ins,isindex,kbd,label,legend,map,menu,noscript,object,optgroup,option,param,textarea,var,ruby,samp,select,rtc,a,h1,h2,h3,h4,h5,font,span,img,table,tr,th,td,hr",
        height: "300px",
        plugins : "imagemanager",
//        paste_auto_cleanup_on_paste : true,
        theme_advanced_buttons1 : "image",
        theme_advanced_buttons2 : "",
        theme_advanced_buttons3 : "",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        //theme_advanced_path_location : "bottom",
        entity_encoding : "raw",
        language : 'en',
        theme_advanced_buttons1_add : ""
    });
}

// function fileBrowserCallBack(field_name, url, type, win) {
////  alert("Example of filebrowser callback: field_name: " + field_name + ", url: " + url + ", type: " + type);
//  win.document.forms[0].elements[field_name].value = "someurl.htm";
// }
function enable_advanced_wysiwyg(selector)
{
    tinyMCE.init({
        mode : "textareas",
        editor_selector : selector,
        theme : "advanced",
        invalid_elements : "div,script,abbr,acronym,address,applet,area,bdo,big,blockquote,button,caption,cite,code,col,colgroup,dd,del,dfn,iframe,input,ins,isindex,kbd,label,legend,map,menu,noscript,object,optgroup,option,param,textarea,var,ruby,samp,select,rtc,span,hr",
        height: "300px",
        plugins : "paste,inlinepopups,imagemanager,contextmenu,table,heading,preview",
        theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,h1,h2,h3,|,justifyleft,justifycenter,justifyright, justifyfull,bullist,numlist,|,image,table",
        theme_advanced_buttons2 : "",
        theme_advanced_buttons3 : "",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        //theme_advanced_path_location : "bottom",
        entity_encoding : "raw",
        language : 'en',
        theme_advanced_buttons1_add : "forecolor,backcolor,separator,link,unlink,,pasteword,removeformat,preview",
        plugin_preview_width : "640",
        plugin_preview_height : "480",
        convert_urls : false,
        setup : function(ed) {
          ed.onInit.add(function() {
            ed.settings.file_browser_callback = function(field_name, url, type, win) {
               if (type == 'image')
                   mcImageManager.filebrowserCallBack(field_name, url, type, win);
               else
                   alert('Do other stuff here');
            };
          });
        }
    });
}

//Khi đã load đầy đủ document, thì setup focus
$(document).ready(function()
{
    set_input_focus();
});